n = int(input(""))
LIST = [int(i) for i in input().split(" ")]
LIST=sorted(LIST)
MIN = 1000*52
for i in range(len(LIST)-1):
for j in range(i+1,len(LIST)):
l=list(LIST)
idx = 0
instab = 0
l.pop(i)
l.pop(j-1)
for k in range(1,len(l),2):
instab += l[k]-l[k-1]
MIN = min(MIN,instab)
print(MIN)
#include <bits/stdc++.h>
using namespace std;
int main() {
int n; cin >> n;
vector<int> v;
for (int i=0;i<2*n;i++){
int x; cin>>x;
v.push_back(x);
}
sort (v.begin(),v.end());
int mininst = 1e9;
for (int i=0; i<2*n;i++){
for (int j=i+1;j<2*n;j++){
vector<int> v2;
for (int k=0;k<2*n;k++){
if (k==i||k==j){
continue;
}
else {
v2.push_back(v[k]);
}
}
int inst=0;
for (int k=0;k<2*n-2;k+=2){
inst += v2[k+1]-v2[k];
}
mininst=min(mininst,inst);
}
}
cout<<mininst;
}
Partitioning binary strings | Special sets |
Smallest chosen word | Going to office |
Color the boxes | Missing numbers |
Maximum sum | 13 Reasons Why |
Friend's Relationship | Health of a person |
Divisibility | A. Movement |
Numbers in a matrix | Sequences |
Split houses | Divisible |
Three primes | Coprimes |
Cost of balloons | One String No Trouble |
Help Jarvis! | Lift queries |
Goki and his breakup | Ali and Helping innocent people |
Book of Potion making | Duration |
Birthday Party | e-maze-in |
Bricks Game | Char Sum |